﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Brouteforce.NewManagers;

namespace Brouteforce.Animation {
    public delegate void OnTransitionDoneHandler();
    
    public abstract class Transition {
        public double Value = 0;
        private double _duration;
        public double StartTime;
        public event OnTransitionDoneHandler OnTransitionDone;
        
        public Transition(double duration) {
            Duration = duration;
        }

        public double Duration {
            get { return _duration; }
            set { _duration = value * 1000; }
        }

        public virtual void startTransition() {
            StartTime = BFGame.CurrentTime.TotalGameTime.TotalMilliseconds;
            Value = 0;
            TransitionManager.Instance.AddTransition(this);
        }

        protected double Time {
            get {
                return BFGame.CurrentTime.TotalGameTime.TotalMilliseconds - StartTime;
            }
        }

        public abstract void interpolate(GameTime time);

        public void ReportFinish() {
            if (OnTransitionDone != null) OnTransitionDone();
        }
    }

    //b = 0, c = 1 , t = Time, d = Duration.
}
